package logic

import (
	"context"
	"userrpc/user"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HandlerNameLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHandlerNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HandlerNameLogic {
	return &HandlerNameLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HandlerNameLogic) HandlerName(req *types.Realnamerequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	realname, err := l.svcCtx.UserSrv.Realname(l.ctx, &user.RealnameRequest{
		Reanlname: req.Realname,
		Idcard:    req.Idcard,
		Userid:    req.Userid,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    0,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "实名认证成功",
		Code:    200,
		Data:    realname,
	}, nil
}
